package prj.carmap.mobile.util;

import prj.carmap.mobile.R;
import android.app.Activity;
import android.graphics.Bitmap;
import android.widget.ImageView;

import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
import com.nostra13.universalimageloader.core.listener.SimpleImageLoadingListener;

public class ImgUtil {
	protected static ImageLoader imageLoader = ImageLoader.getInstance();

	protected static DisplayImageOptions options;
	
	public static void loadImage(ImageView imageView,String uri,Activity activity){
		imageLoader.init(ImageLoaderConfiguration.createDefault(activity));
		options = new DisplayImageOptions.Builder()
		.showImageOnLoading(R.drawable.no_seller_pic)
		.showImageForEmptyUri(R.drawable.no_seller_pic)
		.showImageOnFail(R.drawable.no_seller_pic)
		.cacheInMemory(true)
		.cacheOnDisk(true)
		.considerExifParams(true)
		.bitmapConfig(Bitmap.Config.RGB_565)
		.build();
		imageLoader.displayImage(uri, imageView, options);
		ImageLoader.getInstance().displayImage(uri, imageView, options, null);
	}
	
	public static void loadImage(ImageView imageView,String uri,SimpleImageLoadingListener simpleImageLoadingListener,Activity activity){
		imageLoader.init(ImageLoaderConfiguration.createDefault(activity));
		options = new DisplayImageOptions.Builder()
	//	.showImageOnLoading(R.drawable.ic_stub)
	//	.showImageForEmptyUri(R.drawable.ic_empty)
	//	.showImageOnFail(R.drawable.ic_error)
		.cacheInMemory(true)
		.cacheOnDisk(true)
		.considerExifParams(true)
		.bitmapConfig(Bitmap.Config.RGB_565)
		.build();
		imageLoader.displayImage(uri, imageView, options,simpleImageLoadingListener);
	}
}
